//
//  ViewController.swift
//  TFLeftView
//
//  Created by 李煜 on 2021/9/8.
//

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let tf  = UITextField(frame: CGRect(x: 40, y: 250, width: 300, height: 50))
        view.addSubview(tf)
        tf.borderStyle = .roundedRect
        
        
        let img = UIImage(systemName: "trash.fill")
        let imv = UIImageView(frame: CGRect(x: 8, y: 0, width: 30, height: 30))
        imv.image = img
        imv.sizeToFit()
        
        let overlay = UIView(frame: CGRect(x: 0, y: 0, width: imv.frame.width, height: imv.frame.size.height))
        overlay.addSubview(imv)
        
        tf.leftView = overlay
        tf.leftViewMode = .always
    }


}

